<!DOCTYPE html>
<html lang="zxx">

<head>
    <title>Home</title>
    <!-- Meta tag Keywords -->
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta charset="UTF-8" />
    <meta name="keywords"
        content="Hotair Login Form Responsive web template, Bootstrap Web Templates, Flat Web Templates, Android Compatible web template, Smartphone Compatible web template, free webdesigns for Nokia, Samsung, LG, SonyEricsson, Motorola web design" />
    <!-- //Meta tag Keywords -->
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+JP:wght@400;600;700;900&display=swap" rel="stylesheet">
    <!--/Style-CSS -->
    <link rel="stylesheet" href="assets/css/style.css" type="text/css" media="all" />
    <!--//Style-CSS -->

    <link rel="stylesheet" href="assets/css/font-awesome.min.css" type="text/css" media="all">

</head>

<body>
	<div id="app">
		<!-- form section start -->
		<section class="w3l-hotair-form">
			<h1>LeTaoTao Shopping</h1>
			<div class="container">
				<!-- /form -->
				<div class="workinghny-form-grid">
					<div class="main-hotair">
						<div class="alert-close">
							<span class="fa fa-close"></span>
						</div>
					 
						<div class="content-wthree">
							<h2>Log In</h2>
							<p>To Your Account</p>
							<div>
								<input type="text" v-model="account" class="text" name="text" placeholder="User Name" required="">
								<input type="password" v-model="password" class="password" name="password" placeholder="User Password" required="">
								<button v-on:click="login" class="btn">Log In</button>
							</div>
							<p>Or Connect With Social Media</p>
							<div class="social-icons w3layouts">
								<ul>
									<li>
										<a href="#url" class="facebook"><span class="fa fa-facebook"></span> </a>
									</li>
									<li>
										<a href="#url" class="twitter"><span class="fa fa-twitter"></span> </a>
									</li>
									<li>
										<a href="#url" class="pinterest"><span class="fa fa-pinterest"></span> </a>
									</li>
								</ul>
							</div>
							<p class="account">Don't have an account? <a href="register.html">Register</a></p>
						</div>
						<div class="w3l_form align-self">
							<div class="left_grid_info">
								
							</div>
						</div>
					</div>
				</div>
				<!-- //form -->
			</div>
			<!-- copyright-->
			<div class="copyright text-center">
				<p class="copy-footer-29">来源 &copy; 西华师大最牛逼的团队</p>
			</div>
		</div>
        <!-- //copyright-->
    </section>
    <!-- //form section start -->

    <script src="assets/js/jquery.min.js"></script>
    <script>
        $(document).ready(function (c) {
            $('.alert-close').on('click', function (c) {
                $('.main-hotair').fadeOut('slow', function (c) {
                    $('.main-hotair').remove();
                });
            });
        });
    </script>

</body>

	<script src="assets/js/vue.js"></script>
	<script src="assets/js/axios.min.js"></script>
	<script src="assets/js/const.js"></script>
	
	<script>
		var config={
			"el":"#app",
			"data":{
				"account":"",
				"password":"",
				"power":""
			},
			"methods":{
				selectByaccount:function(){
					//http://localhost:9092/account/selectByaccount?accountAccount=admin
					url = baseUrl + "/account/selectByaccount?accountAccount="+this.account;
					// console.log(url);
					axios.get(url)
					.then(function(response){
						var id = response.data.data.accountId;
						// this.vue.id = id;
						window.localStorage.setItem('userid',id)
						// console.log(this.vue.id);
						// window.alert(this.vue.id);
					})
					.catch()
				},
				login:function(){
					//http://localhost:9092/account/login?accountAccount=admin&accountPassword=123456
					var url = baseUrl+"/account/login?"
					+"&accountAccount="+this.account
					+"&accountPassword="+this.password;
					// console.log(url);
					axios.get(url)
					.then(function(response){
						// window.alert("联网成功");
						var serverResult = response.data;
						var code = serverResult.code;
						this.vue.account = serverResult.data.accountAccount;
						// console.log(this.vue.account);
						// window.alert(this.vue.account);
						//通过当前account查到整个账户的信息，以便取到id,传入id进行修改
						this.vue.selectByaccount();
						
						if(code == 0){
							if(response.data.data.accountPower == 2 || response.data.data.accountPower == 3){
								window.alert("用户/员工登录成功!");
								var id = window.localStorage.getItem('userid');
								var url = "indextest.html?id=" + id;
								window.location.href=url;
								}else{
									window.alert("管理员登录成功!");
									var id = window.localStorage.getItem('userid');
									var url = "indextest-master.html?id=" + id;
									window.location.href=url;
								}
						}else{
						}
					})
					.catch(function(response){
						window.alert("登录失败!请重试");
					});
					
				}
			},
		}
		
		var vue = new Vue(config);
	</script>

</html>